<?php
/**
 * Created by PhpStorm.
 * User: xiao
 * Date: 2018/4/23
 * Time: 11:21
 */

namespace App\Http\Base;


use App\Http\Utils\JUtil;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;

class BaseRequest extends FormRequest
{
    /**
     * 返回错误信息
     * @param Validator $validator
     */
    protected function failedValidation(Validator $validator)
    {
        $msg = $this->formatErrors($validator);
        JUtil::validationError($msg);
    }

    protected function formatErrors(Validator $validator)
    {
        return $validator->errors()->first();
    }
}